<?php
class Util{
	static function getTypeDocumento($typeDocument){
		switch($typeDocument) {
			case 'D':
				return "dni";
				break;
			case 'P':
				return "pasaporte";
				break;
			case 'C':
				return "carnetconducir";
				break;
			case 'I':
				return "cartaidentidad";
				break;
			case 'N':
				return "permisoresidenciaespanol";
				break;
			case 'X':
				return "permisoresidenciapaisUE";
			default:
				return '';
		}
	}
	
	static function getTitulo($sexo){
		if($sexo == "H")
			return sfContext::getInstance()->getI18n()->__("sr", $args, 'messages');
		else
			return sfContext::getInstance()->getI18n()->__("sra", $args, 'messages');
	}
	
	static function getTituloForm($sexo){
		if($sexo == "H")
			return sfContext::getInstance()->getI18n()->__("hombre", $args, 'forms');
		else
			return sfContext::getInstance()->getI18n()->__("mujer", $args, 'forms');
	}
	
	static function getCountry($code) {
		$countryWidget = new sfWidgetFormI18nChoiceCountry(array('culture'   => sfContext::getInstance()->getUser()->getLangCulture(), 'countries' => $countries, 'default' => strtoupper(sfContext::getInstance()->getUser()->getLangCulture())));
		$countries = $countryWidget->getChoices();
		$code = strtoupper($code);
		if (array_key_exists($code, $countries)) {
			return $countries[$code];
		}
		return false;
	}
	
	//Devuelve el string acortado al límite $numCaracteres, incluidos tres puntos suspensivos
	static function getPalabraAcortada($texto, $numCaracteres){
		if(strlen($texto) > $numCaracteres+3)
			return substr($texto, 0, $numCaracteres)."...";
		else
			return $texto;
	}
	
}